package com.yhc.user.api;

import com.yhc.common.dto.BaseResult;
import com.yhc.user.api.request.BuyGoodsRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@FeignClient(name = "user" , path = "/user")
public interface UserApi {

    /**
     * 登录功能不是本次重点， 故返回特定token
     *
     * @param id
     * @return
     */
    @RequestMapping("/login")
    BaseResult<String> login(@RequestParam @NotNull(message = "id不能为空") Long id);


    /**
     * 购买商品（验证分布式事务）
     *
     * @param request
     * @return
     */
    @PostMapping("/buy")
    BaseResult<?> buy(@RequestBody @Valid BuyGoodsRequest request);

}
